<template>
  <div class="mine">
    <div class="header">
      <div class="left">
        <img
          src="https://www.pmdaniu.com/storages/101027/ba18b5f48ada3273e098f37e8715880e-30118/images/%E6%88%91%E7%9A%84/u3527.png"
          alt=""
        />
      </div>
      <div class="right">
        <div class="name">{{ username }}</div>
        <div class="phone">尚未完善用户信息</div>
      </div>
      <div class="logout" @click="logout">注销</div>
    </div>
    <div class="header-nav">
      <div class="item">
        <div class="name">收藏夹</div>
        <div class="num">0</div>
      </div>
      <div class="item">
        <div class="name">关注店铺</div>
        <div class="num">0</div>
      </div>
      <div class="item">
        <div class="name">足迹</div>
        <div class="num">0</div>
      </div>
      <div class="item">
        <div class="name">卡劵</div>
        <div class="num">0</div>
      </div>
    </div>
    <div class="myOrder">
      <div class="title">我的订单</div>
      <div class="col">
        <div class="item">
          <img
            src="https://www.pmdaniu.com/storages/101027/ba18b5f48ada3273e098f37e8715880e-30118/images/%E8%AE%BE%E8%AE%A1%E8%A7%84%E8%8C%83/u291.png"
            alt=""
          />
          <div class="name">待付款</div>
        </div>
        <div class="item">
          <img
            src="https://www.pmdaniu.com/storages/101027/ba18b5f48ada3273e098f37e8715880e-30118/images/%E8%AE%BE%E8%AE%A1%E8%A7%84%E8%8C%83/u295.png"
            alt=""
          />
          <div class="name">待收货</div>
        </div>
        <div class="item">
          <img
            src="https://www.pmdaniu.com/storages/101027/ba18b5f48ada3273e098f37e8715880e-30118/images/%E8%AE%BE%E8%AE%A1%E8%A7%84%E8%8C%83/u299.png"
            alt=""
          />
          <div class="name">已完成</div>
        </div>
        <div class="item">
          <img
            src="https://www.pmdaniu.com/storages/101027/ba18b5f48ada3273e098f37e8715880e-30118/images/%E8%AE%BE%E8%AE%A1%E8%A7%84%E8%8C%83/u306.png"
            alt=""
          />
          <div class="name">退款/售后</div>
        </div>
      </div>
    </div>
    <div class="foryou-title">
      <img
        src="https://www.pmdaniu.com/storages/101027/ba18b5f48ada3273e098f37e8715880e-30118/images/我的/u3583.png"
        alt=""
      />
      <div class="name">为你推荐</div>
      <img
        src="https://www.pmdaniu.com/storages/101027/ba18b5f48ada3273e098f37e8715880e-30118/images/我的/u3583.png"
        alt=""
      />
    </div>
    <div class="foryou-content">
      <div
        class="foryou-item"
        v-for="item in goodslist"
        :key="item.id"
        @click="getDetail(item.id)"
      >
        <div class="imgbox">
          <img :src="item.src" alt="" />
        </div>
        <div class="msg van-multi-ellipsis--l2">
          {{ item.goodmsg }}
        </div>
        <div class="price">￥{{ item.goodprice }}</div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
$main: #c1ab96;
.header {
  background-color: $main;
  padding: 20px;
  display: flex;
  align-items: center;
  color: white;
  .left {
    width: 80px;
    height: 80px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .right {
    .name {
      font-size: 24px;
      font-weight: 700;
    }
    .phone {
      font-size: 14px;
    }
  }
  .logout {
    border: 1px solid white;
    width: 50px;
    height: 30px;
    text-align: center;
    margin-left: 50px;
    line-height: 30px;
    // background-color: #fff;
    color: white;
    border-radius: 99px;
  }
}
.header-nav {
  display: flex;
  color: white;
  padding: 20px;
  font-size: 18px;
  justify-content: space-around;
  text-align: center;
  line-height: 24px;
  background-color: $main;
}
.myOrder {
  background-color: white;
  padding: 20px;
  border-radius: 15px;
  margin-top: -10px;
  .title {
    font-weight: 700;
    font-size: 20px;
    margin-bottom: 10px;
  }
  .col {
    display: flex;
    justify-content: space-around;
    .item {
      width: 25%;
      text-align: center;
      img {
        width: 30px;
        height: 30px;
      }
      .name {
        font-size: 14px;
        line-height: 32px;
      }
    }
  }
}
.foryou-content {
  // background-color: $main;
  padding: 10px;
  margin-bottom: 70px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;

  .foryou-item {
    background-color: #fff;
    width: 48%;
    margin-top: 15px;
    // width: 165px;
    // height: 260px;
    position: relative;
    box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.349019607843137);

    .msg {
      padding: 0 10px;
      font-size: 16px;
      text-align: left;
    }
    .price {
      font-size: 16px;
      font-weight: 700;
      color: #c1ab96;
      text-align: left;
      margin-top: 10px;
      padding: 10px 10px;
      position: relative;
    }
    .imgbox {
      width: 100%;
      height: auto;
      // background-color: red;
      overflow: hidden;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
}
.foryou-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  img {
    flex: 2;
    height: 2px;
  }
  .name {
    flex: 1;
    text-align: center;
    font-size: 16px;
  }
}
</style>
<script>
import goodsModel from "../model/goodsModel";
export default {
  data() {
    return {
      bannerlist: [],
      goodslist: [],
      username: "",
    };
  },
  created() {
    //判断是否登录
    // console.log(!localStorage.getItem("username"));
    if (!localStorage.getItem("username")) {
      this.$router.history.push("login");
    }

    this.username = localStorage.getItem("username");
    goodsModel.query({ classify: "上衣" }).then((res) => {
      this.goodslist = res.data;
    });
  },
  methods: {
    logout() {
      confirm("您想好要注销吗?");
      window.localStorage.removeItem("username");
      this.$router.history.push("login");
    },
    getDetail(id) {
      // console.log(11);
      this.$router.history.push({
        name: "detail",
        params: { id },
      });
      // this.$router.go(0);
    },
  },
};
</script>